Add GtkClipboardTargetReceivedFunc, gtk_clipboard_request_targets() and
authorMatthias Clasen <maclas@gmx.de>
Wed, 24 Dec 2003 00:14:15 +0000 (00:14 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Wed, 24 Dec 2003 00:14:15 +0000 (00:14 +0000)
Wed Dec 24 01:12:53 2003  Matthias Clasen  <maclas@gmx.de>

* gtk/gtkclipboard.[hc]: Add GtkClipboardTargetReceivedFunc,
gtk_clipboard_request_targets() and
gtk_clipboard_wait_for_targets().  (#101774, Dom Lachowicz)

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
docs/reference/ChangeLog
docs/reference/gtk/gtk-sections.txt
docs/reference/gtk/tmpl/gtkclipboard.sgml
gtk/gtkclipboard.c
gtk/gtkclipboard.h

index 4b5a6c8c5131a34729ecf5c108c0cbc0c7ffa81d..4f1b0b029bea59289dfcaf0a64f8fc31d9f3bbc4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Wed Dec 24 01:12:53 2003  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkclipboard.[hc]: Add GtkClipboardTargetReceivedFunc,
+       gtk_clipboard_request_targets() and 
+       gtk_clipboard_wait_for_targets().  (#101774, Dom Lachowicz)
+
 Mon Dec 22 00:40:39 2003  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkcalendar.c (gtk_calendar_paint_arrow): Use 
index 4b5a6c8c5131a34729ecf5c108c0cbc0c7ffa81d..4f1b0b029bea59289dfcaf0a64f8fc31d9f3bbc4 100644 (file)
@@ -1,3 +1,9 @@
+Wed Dec 24 01:12:53 2003  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkclipboard.[hc]: Add GtkClipboardTargetReceivedFunc,
+       gtk_clipboard_request_targets() and 
+       gtk_clipboard_wait_for_targets().  (#101774, Dom Lachowicz)
+
 Mon Dec 22 00:40:39 2003  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkcalendar.c (gtk_calendar_paint_arrow): Use 
index 4b5a6c8c5131a34729ecf5c108c0cbc0c7ffa81d..4f1b0b029bea59289dfcaf0a64f8fc31d9f3bbc4 100644 (file)
@@ -1,3 +1,9 @@
+Wed Dec 24 01:12:53 2003  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkclipboard.[hc]: Add GtkClipboardTargetReceivedFunc,
+       gtk_clipboard_request_targets() and 
+       gtk_clipboard_wait_for_targets().  (#101774, Dom Lachowicz)
+
 Mon Dec 22 00:40:39 2003  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkcalendar.c (gtk_calendar_paint_arrow): Use 
index 4b5a6c8c5131a34729ecf5c108c0cbc0c7ffa81d..4f1b0b029bea59289dfcaf0a64f8fc31d9f3bbc4 100644 (file)
@@ -1,3 +1,9 @@
+Wed Dec 24 01:12:53 2003  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkclipboard.[hc]: Add GtkClipboardTargetReceivedFunc,
+       gtk_clipboard_request_targets() and 
+       gtk_clipboard_wait_for_targets().  (#101774, Dom Lachowicz)
+
 Mon Dec 22 00:40:39 2003  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkcalendar.c (gtk_calendar_paint_arrow): Use 
index 4b5a6c8c5131a34729ecf5c108c0cbc0c7ffa81d..4f1b0b029bea59289dfcaf0a64f8fc31d9f3bbc4 100644 (file)
@@ -1,3 +1,9 @@
+Wed Dec 24 01:12:53 2003  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkclipboard.[hc]: Add GtkClipboardTargetReceivedFunc,
+       gtk_clipboard_request_targets() and 
+       gtk_clipboard_wait_for_targets().  (#101774, Dom Lachowicz)
+
 Mon Dec 22 00:40:39 2003  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkcalendar.c (gtk_calendar_paint_arrow): Use 
index a39ee8eae038ad26ad35112421be0775044b05b3..3c319711f2cb7acb8d4a2866cbbb5c8668853980 100644 (file)
@@ -1,3 +1,12 @@
+Wed Dec 24 01:12:12 2003  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtk-sections.txt: Add GtkClipboardTargetReceivedFunc,
+       gtk_clipboard_request_targets, gtk_clipboard_wait_for_targets.
+
+Wed Dec 24 01:11:36 2003  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/tmpl/gtkclipboard.sgml: Document GtkClipboardTargetReceivedFunc.
+
 Sun Dec 21 01:58:33 2003  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtk-sections.txt: Add gtk_menu_shell_cancel.
index 98673762dbc2d38a4aeb7eb610e81465a03016e0..66d918f0515247ca28c00077dde436368af69bd8 100644 (file)
@@ -4743,6 +4743,7 @@ gtk_selection_data_get_type
 GtkClipboard
 GtkClipboardReceivedFunc
 GtkClipboardTextReceivedFunc
+GtkClipboardTargetsReceivedFunc
 GtkClipboardGetFunc
 GtkClipboardClearFunc
 gtk_clipboard_get
@@ -4755,9 +4756,11 @@ gtk_clipboard_clear
 gtk_clipboard_set_text
 gtk_clipboard_request_contents
 gtk_clipboard_request_text
+gtk_clipboard_request_targets
 gtk_clipboard_wait_for_contents
 gtk_clipboard_wait_for_text
 gtk_clipboard_wait_is_text_available
+gtk_clipboard_wait_for_targets
 <SUBSECTION Standard>
 GTK_CLIPBOARD
 GTK_TYPE_CLIPBOARD
index 93fffa8be1346959955c79f1d6c1d19c3ba0b0bc..a04634dc8adf272be0559465360c470e093e6839 100644 (file)
@@ -115,6 +115,20 @@ Storing data on clipboards
 @data: the @user_data supplied to gtk_clipboard_request_text().
 
 
+<!-- ##### USER_FUNCTION GtkClipboardTargetsReceivedFunc ##### -->
+<para>
+    A function to be called when the results of gtk_clipboard_request_targets()
+    are received, or when the request fails.
+</para>
+
+@clipboard: the #GtkClipboard
+@atoms: the supported targets, as array of #GdkAtom, or %NULL 
+            if retrieving the data failed.
+@n_atoms: the length of the @atoms array.
+@data: the @user_data supplied to gtk_clipboard_request_targets().
+@Since: 2.4
+
+
 <!-- ##### USER_FUNCTION GtkClipboardGetFunc ##### -->
 <para>
 A function that will be called to provide the contents of the selection.
@@ -253,6 +267,16 @@ will not be used again.
 @user_data: 
 
 
+<!-- ##### FUNCTION gtk_clipboard_request_targets ##### -->
+<para>
+
+</para>
+
+@clipboard: 
+@callback: 
+@user_data: 
+
+
 <!-- ##### FUNCTION gtk_clipboard_wait_for_contents ##### -->
 <para>
 
@@ -269,12 +293,7 @@ will not be used again.
 </para>
 
 @clipboard: 
-@Returns: <!--
-Local variables:
-mode: sgml
-sgml-parent-document: ("../gtk-docs.sgml" "book" "refsect2" "")
-End:
--->
+@Returns: 
 
 
 <!-- ##### FUNCTION gtk_clipboard_wait_is_text_available ##### -->
@@ -286,3 +305,20 @@ End:
 @Returns: 
 
 
+<!-- ##### FUNCTION gtk_clipboard_wait_for_targets ##### -->
+<para>
+
+</para>
+
+@clipboard: 
+@targets: 
+@n_targets: 
+@Returns: 
+
+<!--
+Local variables:
+mode: sgml
+sgml-parent-document: ("../gtk-docs.sgml" "book" "refsect2" "")
+End:
+-->
+
index 1b5d37c80ea647ef6be1ea256b638201627d3424..921b831a968dec3e2013e069d7b66bd85971d976 100644 (file)
@@ -37,6 +37,7 @@ typedef struct _GtkClipboardClass GtkClipboardClass;
 
 typedef struct _RequestContentsInfo RequestContentsInfo;
 typedef struct _RequestTextInfo RequestTextInfo;
+typedef struct _RequestTargetsInfo RequestTargetsInfo;
 
 struct _GtkClipboard 
 {
@@ -72,6 +73,12 @@ struct _RequestTextInfo
   gpointer user_data;
 };
 
+struct _RequestTargetsInfo
+{
+  GtkClipboardTargetsReceivedFunc callback;
+  gpointer user_data;
+};
+
 static void gtk_clipboard_class_init (GtkClipboardClass *class);
 static void gtk_clipboard_finalize   (GObject           *object);
 
@@ -833,6 +840,57 @@ gtk_clipboard_request_text (GtkClipboard                *clipboard,
                                  info);
 }
 
+static void 
+request_targets_received_func (GtkClipboard     *clipboard,
+                              GtkSelectionData *selection_data,
+                              gpointer          data)
+{
+  RequestTargetsInfo *info = data;
+  GdkAtom *targets = NULL;
+  gint n_targets = 0;
+
+  gtk_selection_data_get_targets (selection_data, &targets, &n_targets);
+
+  info->callback (clipboard, targets, n_targets, info->user_data);
+
+  g_free (info);
+  g_free (targets);
+}
+
+/**
+ * gtk_clipboard_request_targets:
+ * @clipboard: a #GtkClipboard
+ * @callback:  a function to call when the targets are received,
+ *             or the retrieval fails. (It will always be called
+ *             one way or the other.)
+ * @user_data: user data to pass to @callback.
+ * 
+ * Requests the contents of the clipboard as list of supported targets. 
+ * When the list is later received, @callback will be called. 
+ *
+ * The @targets parameter to @callback will contain the resulting targets if
+ * the request succeeded, or %NULL if it failed.
+ *
+ * Since: 2.4
+ **/
+void 
+gtk_clipboard_request_targets (GtkClipboard                *clipboard,
+                              GtkClipboardTargetsReceivedFunc callback,
+                              gpointer                     user_data)
+{
+  RequestTargetsInfo *info;
+  
+  g_return_if_fail (clipboard != NULL);
+  g_return_if_fail (callback != NULL);
+  
+  info = g_new (RequestTargetsInfo, 1);
+  info->callback = callback;
+  info->user_data = user_data;
+
+  gtk_clipboard_request_contents (clipboard, gdk_atom_intern ("TARGETS", FALSE),
+                                 request_targets_received_func,
+                                 info);
+}
 
 typedef struct
 {
@@ -1000,3 +1058,49 @@ gtk_clipboard_wait_is_text_available (GtkClipboard *clipboard)
 
   return result;
 }
+
+/**
+ * gtk_clipboard_wait_for_targets
+ * @clipboard: a #GtkClipboard
+ * @targets: location to store an array of targets. The result
+ *           stored here must be freed with g_free().
+ * @n_targets: location to store number of items in @targets.
+ *
+ * Returns a list of targets that are present on the clipboard, or %NULL
+ * if there aren't any targets available. The returned list must be 
+ * freed with g_free().
+ * This function waits for the data to be received using the main 
+ * loop, so events, timeouts, etc, may be dispatched during the wait.
+ *
+ * Return value: %TRUE if any targets are present on the clipboard,
+ *               otherwise %FALSE.
+ *
+ * Since: 2.4
+ */
+gboolean
+gtk_clipboard_wait_for_targets (GtkClipboard  *clipboard, 
+                               GdkAtom      **targets,
+                               gint          *n_targets)
+{
+  GtkSelectionData *data;
+  gboolean result = FALSE;
+  
+  g_return_val_if_fail (clipboard != NULL, FALSE);
+
+  /* TODO: see http://bugzilla.gnome.org/show_bug.cgi?id=101774 with regard to XFIXES */
+
+  if (n_targets)
+    *n_targets = 0;
+      
+  targets = NULL;      
+
+  data = gtk_clipboard_wait_for_contents (clipboard, gdk_atom_intern ("TARGETS", FALSE));
+
+  if (data)
+    {
+      result = gtk_selection_data_get_targets (data, targets, n_targets);
+      gtk_selection_data_free (data);
+    }
+
+  return result;
+}
index b18421bca49d828d0683cc2b77c0390c7fa8eada..3d2268393ad35b14221fcd57a1d34695353d6a7d 100644 (file)
@@ -38,6 +38,10 @@ typedef void (* GtkClipboardReceivedFunc)        (GtkClipboard     *clipboard,
 typedef void (* GtkClipboardTextReceivedFunc)    (GtkClipboard     *clipboard,
                                                  const gchar      *text,
                                                  gpointer          data);
+typedef void (* GtkClipboardTargetsReceivedFunc) (GtkClipboard     *clipboard,
+                                                 GdkAtom          *atoms,
+                                                 gint              n_atoms,
+                                                 gpointer          data);
 
 /* Should these functions have GtkClipboard *clipboard as the first argument?
  * right now for ClearFunc, you may have trouble determining _which_ clipboard
@@ -86,6 +90,9 @@ void gtk_clipboard_request_contents (GtkClipboard                    *clipboard,
 void gtk_clipboard_request_text     (GtkClipboard                    *clipboard,
                                     GtkClipboardTextReceivedFunc     callback,
                                     gpointer                         user_data);
+void gtk_clipboard_request_targets  (GtkClipboard                    *clipboard,
+                                    GtkClipboardTargetsReceivedFunc  callback,
+                                    gpointer                         user_data);
 
 GtkSelectionData *gtk_clipboard_wait_for_contents (GtkClipboard *clipboard,
                                                   GdkAtom       target);
@@ -93,6 +100,10 @@ gchar *           gtk_clipboard_wait_for_text     (GtkClipboard *clipboard);
 
 gboolean gtk_clipboard_wait_is_text_available   (GtkClipboard         *clipboard);
 
+gboolean gtk_clipboard_wait_for_targets (GtkClipboard  *clipboard, 
+                                        GdkAtom      **targets,
+                                        gint          *n_targets);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */